package com.javatest2;

import java.util.Arrays;

/**
 * @author LL
 * 插入排序法()
 * @create 2021-01-19 17:33
 */
public class Subject6 {

    /*
     * @Author LL
     * @Description
     * @Date 10:26 2021/1/20
     * @param a
     * @return void
     * @exception
     **/
    public static void test(final int[] a) {

        for (int i = 0; i < a.length; i++) {
            final int temp = a[i];
            int index = i - 1;
            while (index >= 0 && temp < a[index]) {
                a[index + 1] = a[index];
                index--;
            }
            a[index + 1] = temp;
        }
        System.out.println(Arrays.toString(a));
    }

    public static void main(final String[] args) {
        final int[] a = {12, 4, 3, 78, 34, 90, 2, 5, 3, 0, 7, 4, 8, 9, 0};
        test(a);
    }


}
